Skip to content

Commit 36b6bda

Browse files
committed
when unpinning mirror, do not modify host config
1 parent 93075b8 commit 36b6bda

File tree

1 file changed

+16
-24
lines changed
  • repos/system_upgrade/cloudlinux/actors/unpinclnmirror

1 file changed

+16
-24
lines changed

repos/system_upgrade/cloudlinux/actors/unpinclnmirror/actor.py

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from leapp.libraries.common.cln_switch import get_target_userspace_path
66
from leapp.tags import FirstBootPhaseTag, IPUWorkflowTag
77

8+
89
class UnpinClnMirror(Actor):
910
"""
1011
Remove the pinned CLN mirror.
@@ -16,32 +17,23 @@ class UnpinClnMirror(Actor):
1617
produces = ()
1718
tags = (IPUWorkflowTag, FirstBootPhaseTag)
1819

19-
CLN_REPO_ID = "cloudlinux-x86_64-server-8"
20-
DEFAULT_CLN_MIRROR = "https://xmlrpc.cln.cloudlinux.com/XMLRPC/"
21-
2220
@run_on_cloudlinux
2321
def process(self):
2422
target_userspace = get_target_userspace_path()
2523

26-
for mirrorlist_path in [
27-
'/etc/mirrorlist',
28-
os.path.join(target_userspace, 'etc/mirrorlist'),
29-
]:
30-
try:
31-
os.remove(mirrorlist_path)
32-
except OSError:
33-
self.log.info('Can\'t remove %s, file does not exist, doing nothing', mirrorlist_path)
24+
mirrorlist_path = os.path.join(target_userspace, 'etc/mirrorlist')
25+
try:
26+
os.remove(mirrorlist_path)
27+
except OSError:
28+
self.log.info('Can\'t remove %s, file does not exist, doing nothing', mirrorlist_path)
3429

35-
for up2date_path in [
36-
'/etc/sysconfig/rhn/up2date',
37-
os.path.join(target_userspace, 'etc/sysconfig/rhn/up2date'),
38-
]:
39-
try:
40-
with open(up2date_path, 'r') as file:
41-
lines = [
42-
line for line in file.readlines() if 'etc/mirrorlist' not in line
43-
]
44-
with open(up2date_path, 'w') as file:
45-
file.writelines(lines)
46-
except (OSError, IOError, ValueError):
47-
self.log.info('Can update %s file, doing nothing', up2date_path)
30+
up2date_path = os.path.join(target_userspace, 'etc/sysconfig/rhn/up2date')
31+
try:
32+
with open(up2date_path, 'r') as file:
33+
lines = [
34+
line for line in file.readlines() if 'etc/mirrorlist' not in line
35+
]
36+
with open(up2date_path, 'w') as file:
37+
file.writelines(lines)
38+
except (OSError, IOError, ValueError):
39+
self.log.info('Can update %s file, doing nothing', up2date_path)

0 commit comments

Comments
 (0)