本文整理汇总了Python中pulp_rpm.handlers.repo_file.RepoFile.remove_repo_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python RepoFile.remove_repo_by_name方法的具体用法?Python RepoFile.remove_repo_by_name怎么用?Python RepoFile.remove_repo_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp_rpm.handlers.repo_file.RepoFile
的用法示例。
在下文中一共展示了RepoFile.remove_repo_by_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_repo
# 需要导入模块: from pulp_rpm.handlers.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handlers.repo_file.RepoFile import remove_repo_by_name [as 别名]
def test_delete_repo(self):
"""
Tests removing an existing repo is correctly saved and loaded
"""
# Setup
repo1 = Repo('test-repo-1')
repo2 = Repo('test-repo-2')
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.add_repo(repo1)
repo_file.add_repo(repo2)
repo_file.save()
# Test
repo_file.remove_repo_by_name('test-repo-1')
repo_file.save()
# Verify
loaded = RepoFile(TEST_REPO_FILENAME)
loaded.load()
self.assertEqual(1, len(loaded.all_repos()))
self.assertTrue(loaded.get_repo('test-repo-1') is None)
self.assertTrue(loaded.get_repo('test-repo-2') is not None)
示例2: test_delete_repo_no_repo
# 需要导入模块: from pulp_rpm.handlers.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handlers.repo_file.RepoFile import remove_repo_by_name [as 别名]
def test_delete_repo_no_repo(self):
"""
Ensures that an error is not thrown when a repo that does not exist is
deleted from the repo file.
"""
# Setup
repo_file = RepoFile(TEST_REPO_FILENAME)
repo_file.add_repo(Repo('test-repo-1'))
# Test
repo_file.remove_repo_by_name('foo')
# Verify
self.assertTrue(repo_file.get_repo('test-repo-1') is not None)
示例3: unbind
# 需要导入模块: from pulp_rpm.handlers.repo_file import RepoFile [as 别名]
# 或者: from pulp_rpm.handlers.repo_file.RepoFile import remove_repo_by_name [as 别名]
def unbind(repo_filename, mirror_list_filename, keys_root_dir, cert_root_dir, repo_id, lock=None):
"""
Removes the repo identified by repo_id from the given repo file. If the repo is
not bound, this call has no effect. If the mirror list file exists, it will be
deleted.
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 removed; if this file does not exist
this call has no effect
@type repo_filename: string
@param mirror_list_filename: full path to the location of the mirror list file
that may exist for the given repo; if the file does
not exist this field will be ignored
@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: identifies the repo in the repo file to delete
@type repo_id: string
@param lock: if the default lock is unacceptable, it may be overridden in this variable
@type lock: L{Lock}
"""
if not lock:
lock = Lock(LOCK_FILE)
lock.acquire()
try:
log.info('Unbinding repo [%s]' % repo_id)
if not os.path.exists(repo_filename):
return
# Repo file changes
repo_file = RepoFile(repo_filename)
repo_file.load()
repo_file.remove_repo_by_name(repo_id) # will not throw an error if repo doesn't exist
repo_file.save()
# Mirror list removal
if os.path.exists(mirror_list_filename):
os.remove(mirror_list_filename)
# Keys removal
repo_keys = RepoKeyFiles(keys_root_dir, repo_id)
repo_keys.update_filesystem()
# cert removal
certificates = CertFiles(cert_root_dir, repo_id)
certificates.apply()
finally:
lock.release()