RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2118486 - The force option of registering through dbus python binding is ignored
Summary: The force option of registering through dbus python binding is ignored
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.6
Hardware: All
OS: All
medium
medium
Target Milestone: rc
: 8.8
Assignee: Jason Jerome
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks: 2121350
TreeView+ depends on / blocked
 
Reported: 2022-08-15 22:18 UTC by Michal Bocek
Modified: 2023-05-16 11:10 UTC (History)
5 users (show)

Fixed In Version: subscription-manager-1.28.34-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2121350 (view as bug list)
Environment:
Last Closed: 2023-05-16 09:07:12 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 3161 0 None Merged 2118486: [1.28] Implement "force" register option in rhsm dbus python binding 2022-11-22 12:19:29 UTC
Red Hat Issue Tracker RHELPLAN-131137 0 None None None 2022-08-15 22:19:30 UTC
Red Hat Product Errata RHBA-2023:2984 0 None None None 2023-05-16 09:07:36 UTC

Description Michal Bocek 2022-08-15 22:18:12 UTC
Description of problem:
The dbus object com.redhat.RHSM1 documented at https://www.candlepinproject.org/docs/subscription-manager/dbus_objects.html#methods-6 mentions that we can set the force option when registering the system that should be the equivalent of the --force cli option.

This option is not respected when passing the force option through the RHSM dbus python binding.

Version-Release number of selected component (if applicable):


Steps to Reproduce:
1. Have a RHEL 8 system registered to RHSM
2. Run this piece of python code
```
import dbus

REGISTER_OPTS_DICT = dbus.Dictionary({"force": True}, signature="ss")

system_bus = dbus.SystemBus()
register_server = system_bus.get_object("com.redhat.RHSM1", "/com/redhat/RHSM1/RegisterServer")
address = register_server.Start("C", dbus_interface="com.redhat.RHSM1.RegisterServer")
private_bus = dbus.connection.Connection(address)
register_object = private_bus.get_object("com.redhat.RHSM1", "/com/redhat/RHSM1/Register")
connection_opts = {"host": "subscription.rhsm.redhat.com"}
connection_opts = dbus.Dictionary(connection_opts, signature="ss")
register_object.Register(
    "",
    "username",
    "password",
    REGISTER_OPTS_DICT,
    connection_opts,
    "C",
    dbus_interface="com.redhat.RHSM1.Register",
)
```

Actual results:
You're greeted with the following exception:

com.redhat.RHSM1.Error: {"exception": "DBusException", "message": "This system is already registered", "severity": "error"}

Expected results:
The system is re-registered without an exception.

Comment 1 Pino Toscano 2022-08-16 13:00:23 UTC
Yes, it appears it is not actually implemented, only checked as part of the parameters in case a system is registered.

Comment 2 Archana Pandey 2022-11-30 10:19:58 UTC
Pre-verification against jenkins build of subscription-manager( subscription-manager-1.28.33+4.gca9258769-1.git.0.244bf50.x86_64 )

>> Lets reproduce the issue first-

[root@sweetpig-12 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 4.2.10-1
subscription management rules: 5.43
subscription-manager: 1.28.33-1.el8
[root@sweetpig-12 ~]# 


[root@sweetpig-12 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Disabled
Content Access Mode is set to Simple Content Access. This host has access to content, regardless of subscription status.

System Purpose Status: Disabled

[root@sweetpig-12 ~]# 
[root@sweetpig-12 ~]# subscription-manager identity 
system identity: 854a3c2f-b568-4fa1-a173-f1da3e7b6582
name: sweetpig-12.4a2m.lab.eng.bos.redhat.com
org name: 13343512
org ID: 13343512
[root@sweetpig-12 ~]#  
[root@sweetpig-12 ~]# python3 test.py                     << script to use dbus python binding for rhsm
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    dbus_interface="com.redhat.RHSM1.Register",
  File "/usr/lib64/python3.6/site-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib64/python3.6/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib64/python3.6/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: com.redhat.RHSM1.Error: {"exception": "DBusException", "severity": "error", "message": "This system is already registered"}
[root@sweetpig-12 ~]#    ^^^^^------ Issue reproduced, forced re-registration failed
[root@sweetpig-12 ~]# 

=========================================================================

>> verifying on jenkins build of sub-man that has a fix:

[root@sweetpig-12 ~]# 
[root@sweetpig-12 ~]# yum upgrade subscription-manager
Updating Subscription Management repositories.
Last metadata expiration check: 3:49:40 ago on Wed 30 Nov 2022 01:16:13 AM EST.
Dependencies resolved.
==============================================================================================================================================================================================
 Package                                                  Architecture                  Version                                                     Repository                           Size
==============================================================================================================================================================================================
Upgrading:
 dnf-plugin-subscription-manager                          x86_64                        1.28.33+4.gca9258769-1.git.0.244bf50                        rhsm_RHEL8.8                        315 k
 python3-cloud-what                                       x86_64                        1.28.33+4.gca9258769-1.git.0.244bf50                        rhsm_RHEL8.8                        314 k
 python3-subscription-manager-rhsm                        x86_64                        1.28.33+4.gca9258769-1.git.0.244bf50                        rhsm_RHEL8.8                        392 k
 python3-syspurpose                                       x86_64                        1.28.33+4.gca9258769-1.git.0.244bf50                        rhsm_RHEL8.8                        331 k
 subscription-manager                                     x86_64                        1.28.33+4.gca9258769-1.git.0.244bf50                        rhsm_RHEL8.8                        1.2 M

Transaction Summary
=========================================================================:
:
:
:
Installed products updated.

Upgraded:
  dnf-plugin-subscription-manager-1.28.33+4.gca9258769-1.git.0.244bf50.x86_64                           python3-cloud-what-1.28.33+4.gca9258769-1.git.0.244bf50.x86_64                        
  python3-subscription-manager-rhsm-1.28.33+4.gca9258769-1.git.0.244bf50.x86_64                         python3-syspurpose-1.28.33+4.gca9258769-1.git.0.244bf50.x86_64                        
  subscription-manager-1.28.33+4.gca9258769-1.git.0.244bf50.x86_64                                     

Complete!
[root@sweetpig-12 ~]# 
[root@sweetpig-12 ~]# service rhsm restart
Redirecting to /bin/systemctl restart rhsm.service
[root@sweetpig-12 ~]# 
[root@sweetpig-12 ~]# subscription-manager identity
system identity: aa942526-4fec-42aa-9516-159cb2dede17
name: sweetpig-12.4a2m.lab.eng.bos.redhat.com
org name: 13343512
org ID: 13343512
[root@sweetpig-12 ~]# 
[root@sweetpig-12 ~]# python3 test.py 
[root@sweetpig-12 ~]#                 ^^----  script ran successfully and system re-registered with force option.      
[root@sweetpig-12 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Disabled
Content Access Mode is set to Simple Content Access. This host has access to content, regardless of subscription status.

System Purpose Status: Disabled

[root@sweetpig-12 ~]# 
[root@sweetpig-12 ~]# subscription-manager identity
system identity: cd0a578f-ac67-4a48-8323-2ec8678f574b                               system identity after re-registration with force option
name: sweetpig-12.4a2m.lab.eng.bos.redhat.com
org name: 13343512
org ID: 13343512
[root@sweetpig-12 ~]# 
[root@sweetpig-12 ~]#

Verified :  The system is re-registered without an exception when using --force option .

Comment 5 Zdenek Petracek 2022-12-06 14:39:32 UTC
Final verification done on the SM version:
[root@kvm-02-guest12 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 4.2.10-1
subscription management rules: 5.43
subscription-manager: 1.28.34-1.el8

[root@kvm-02-guest12 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Disabled
Content Access Mode is set to Simple Content Access. This host has access to content, regardless of subscription status.

System Purpose Status: Disabled

[root@kvm-02-guest12 ~]# subscription-manager identity
system identity: 16aa5474-5817-4c91-8712-7aeab6d48953
name: kvm-02-guest12.rhts.eng.brq.redhat.com
org name: 13281785
org ID: 13281785


-> Running a script to use dbus python binding for rhsm:
[root@kvm-02-guest12 ~]# python3 script.py
[root@kvm-02-guest12 ~]#
[root@kvm-02-guest12 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Disabled
Content Access Mode is set to Simple Content Access. This host has access to content, regardless of subscription status.

System Purpose Status: Disabled

[root@kvm-02-guest12 ~]# subscription-manager identity
system identity: 322af5ac-28f3-48d3-b5a7-24e6309ac686
name: kvm-02-guest12.rhts.eng.brq.redhat.com
org name: 13281785
org ID: 13281785


^^ system re-registered successfully --> Final verification PASSED

Comment 8 errata-xmlrpc 2023-05-16 09:07:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (subscription-manager bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2984


Note You need to log in before you can comment on or make changes to this bug.