本文整理汇总了Python中pulp_rpm.handler.repo_file.RepoFile.update_repo方法的典型用法代码示例。如果您正苦于以下问题:Python RepoFile.update_repo方法的具体用法?Python RepoFile.update_repo怎么用?Python RepoFile.update_repo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp_rpm.handler.repo_file.RepoFile
的用法示例。
在下文中一共展示了RepoFile.update_repo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_repo
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import update_repo [as 别名]
def test_update_repo(self):
"""
Tests that updating an existing repo is correctly saved.
"""
# Setup
repo1 = Repo('test-repo-1')
repo1['baseurl'] = 'http://localhost/repo1'
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.add_repo(repo1)
repo_file.save()
# Test
repo1['baseurl'] = 'http://localhost/repo-updated'
repo_file.update_repo(repo1)
repo_file.save()
# Verify
loaded = RepoFile(TEST_REPO_FILENAME)
loaded.load()
found_repo = loaded.get_repo('test-repo-1')
self.assertEqual(found_repo['baseurl'], 'http://localhost/repo-updated')
示例2: bind
# 需要导入模块: from pulp_rpm.handler.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handler.repo_file.RepoFile import update_repo [as 别名]
def bind(repo_filename,
mirror_list_filename,
keys_root_dir,
cert_root_dir,
repo_id,
repo_name,
url_list,
gpg_keys,
cacert,
clientcert,
enabled,
lock=None):
"""
Uses the given data to safely bind a repo to a repo file. This call will
determine the best method for representing the repo given the data in the
repo object as well as the list of URLs where the repo can be found.
The default lock is defined at the module level and is
used to ensure that concurrent access to the give files is prevented. Specific
locks can be passed in for testing purposes to circumvent the default
location of the lock which requires root access.
@param repo_filename: full path to the location of the repo file in which
the repo will be bound; this file does not need to
exist prior to this call
@type repo_filename: string
@param mirror_list_filename: full path to the location of the mirror list file
that should be written for the given repo if
necessary; this should be unique for the given repo
@type mirror_list_filename: string
@param keys_root_dir: absolute path to the root directory in which the keys for
all repos will be stored
@type keys_root_dir: string
@param cert_root_dir: absolute path to the root directory in which the certs for
all repos will be stored
@type cert_root_dir: string
@param repo_id: uniquely identifies the repo being updated
@type repo_id: string
@param repo_name: the repo name
@type repo_name: str
@param url_list: list of URLs that will be used to access the repo; this call
will determine the best way to represent the URL list in
the repo definition
@type url_list: list of strings
@param gpg_keys: mapping of key name to contents for GPG keys to be used when
verifying packages from this repo
@type gpg_keys: dict {string: string}
@param cacert: The CA certificate (PEM).
@type cacert: str
@param clientcert: The client certificate (PEM).
@type clientcert: str
@param lock: if the default lock is unacceptble, it may be overridden in this variable
@type lock: L{Lock}
"""
if not lock:
lock = Lock('/var/run/subsys/pulp/repolib.pid')
lock.acquire()
try:
log.info('Binding repo [%s]' % repo_id)
repo_file = RepoFile(repo_filename)
repo_file.load()
# In the case of an update, only the changed values will have been sent.
# Therefore, any of the major data components (repo data, url list, keys)
# may be None.
if repo_name is not None:
repo = _convert_repo(repo_id, enabled, repo_name)
else:
repo = repo_file.get_repo(repo_id)
if gpg_keys is not None:
_handle_gpg_keys(repo, gpg_keys, keys_root_dir)
_handle_certs(repo, cert_root_dir, cacert, clientcert)
if url_list is not None:
_handle_host_urls(repo, url_list, mirror_list_filename)
if repo_file.get_repo(repo.id):
log.info('Updating existing repo [%s]' % repo.id)
repo_file.update_repo(repo)
else:
log.info('Adding new repo [%s]' % repo.id)
repo_file.add_repo(repo)
repo_file.save()
#.........这里部分代码省略.........