Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
ovirt-engine-hyper-upgrade: Enable/Disable with single cmd
  • Loading branch information
dougsland committed Dec 12, 2017
1 parent 6c14f3a commit 94cf671
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions src/ovirt-engine-hyper-upgrade
Expand Up @@ -292,47 +292,44 @@ class Subscriptions(Base):
Returns: command output
'''

SUBSCRIPTION_MANAGER_CMD = [
'env',
'LC_ALL=C',
'subscription-manager',
'repos'
]

if 'enable' == action:
rhsm_enable_cmd = list(SUBSCRIPTION_MANAGER_CMD)
for repo in repos:
self.print_msg(
'Enabling repository: {r}'.format(r=repo),
MsgType.INFO
)
rhsm_enable_cmd.extend(['--enable', repo])

if self.execute_cmd([
'env',
'LC_ALL=C',
'subscription-manager',
'repos',
'--enable',
repo
]) != 0:
self.print_msg(
'Cannot enable repository: {r}'.format(r=repo),
MsgType.ERROR
)
sys.exit(2)
if self.execute_cmd(rhsm_enable_cmd) != 0:
self.print_msg(
'Cannot enable repository: {r}'.format(r=repo),
MsgType.ERROR
)
sys.exit(2)

elif 'disable' == action:
rhsm_disable_cmd = list(SUBSCRIPTION_MANAGER_CMD)
for repo in repos:
self.print_msg(
'Disabling repository: {r}'.format(r=repo),
MsgType.INFO
)
rhsm_disable_cmd.extend(['--disable', repo])

if self.execute_cmd([
'env',
'LC_ALL=C',
'subscription-manager',
'repos',
'--disable',
repo
]) != 0:
self.print_msg(
'Cannot disable repository: {r}'.format(r=repo),
MsgType.ERROR
)
sys.exit(2)
if self.execute_cmd(rhsm_disable_cmd) != 0:
self.print_msg(
'Cannot disable repository: {r}'.format(r=repo),
MsgType.ERROR
)
sys.exit(2)
else:
raise RuntimeError(
"Unknown action [%s] for repositories!" % action
Expand Down

0 comments on commit 94cf671

Please sign in to comment.