Bug 1632283

Summary: [RFE] subscription-manager and syspurpose should warn when setting a role, addon, usage, or SLA not available for the organization.
Product: Red Hat Enterprise Linux 8 Reporter: Kevin Howell <khowell>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: high    
Version: 8.0CC: cdonnell, csnyder, jbhatia, jsefler, mkolman, pdudley, pdwyer, peter.vreman, qianzhan, redakkan, rjerrido, saydas, swadeley
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 01:38:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1618398, 1632253    
Bug Blocks: 1661414    

Description Kevin Howell 2018-09-24 14:39:25 UTC
Description of problem: When setting role, addon, usage, or SLA, subscription-manager should query available values for the org, and display an appropriate warning.

Comment 1 Craig Donnelly 2018-09-26 22:42:36 UTC
It is worth nothing that this blocks registration in its current state:

[root@unused syspurpose]# rpm -q subscription-manager
subscription-manager-1.23.6-1.el8.x86_64
[root@unused syspurpose]# syspurpose set-sla BAD
service_level_agreement set to BAD
Unable to read consumer certificate: Error loading certificate: [Errno 2] No such file or directory: '/etc/pki/consumer/cert.pem'
Unable to sent system purpose to candlepin server
[root@unused syspurpose]# subscription-manager register --username xx --password xx
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
HTTP error (400 - Bad Request): Service level "BAD" is not available to units of organization 11336955.
[root@unused syspurpose]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Unknown

System Purpose Status: Unknown

[root@unused syspurpose]# subscription-manager identity
This system is not yet registered. Try 'subscription-manager register --help' for more information.

Comment 2 qianzhan 2018-11-02 08:38:24 UTC
(In reply to Craig Donnelly from comment #1)
> It is worth nothing that this blocks registration in its current state:
> 

See Also: https://bugzilla.redhat.com/show_bug.cgi?id=1641414

Comment 9 Rehana 2020-09-09 14:50:54 UTC
With a latest subscription manager version, containing the feature to list system purpose values  Bug 1634023 we have also incorporated this request . Below is the small demonstration of them 

# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.1.18-1
subscription management rules: 5.41
subscription-manager: 1.27.15-1.el8

On registered system , try setting invalid system purpose values 
# subscription-manager list --installed 
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Enterprise Linux for x86_64 High Touch Beta
Product ID:     230
Version:        8.3 HTB
Arch:           x86_64
Status:         Subscribed
Status Details: 
Starts:         12/11/2019
Ends:           12/10/2020

# subscription-manager role --set=bar
Warning: Provided value "bar" is not included in the list of valid values
 - Red Hat Enterprise Linux Workstation
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node
role set to "bar".

# subscription-manager usage --set=test
Warning: Provided value "test" is not included in the list of valid values
 - Development/Test
 - Production
 - Disaster Recovery
usage set to "test".

# subscription-manager usage --set=QE
Warning: Provided value "QE" is not included in the list of valid values
 - Development/Test
 - Production
 - Disaster Recovery
usage set to "QE".

^^ Notice that we currently show a warning message when user trying to set system purpose values to an invalid data.We still honour the data provided by user and set the value , but we hope this extra line of warning will help users validate the value.
  
# syspurpose show
{
  "role": "bar",
  "service_level_agreement": "foo",
  "usage": "QE"
}


On a unregistered a system , when username/password/org details are provided the current implementation also displays the warning message 

# subscription-manager identity
This system is not yet registered. Try 'subscription-manager register --help' for more information.

# subscription-manager role --username=****** --password=***** --set=foo
Organization: *****
Warning: Provided value "foo" is not included in the list of valid values
 - Red Hat Enterprise Linux Workstation
 - Red Hat Enterprise Linux Server
 - Red Hat Enterprise Linux Compute Node
role set to "foo".

# subscription-manager service-level --username=****** --password=***** --set=foo
Organization: *****
Warning: Provided value "foo" is not included in the list of valid values
 - Dev-Enterprise
 - Layered
 - Standard
 - Premium
 - Self-Support
service_level_agreement set to "foo".

# subscription-manager usage --username=****** --password=***** --set=foo
Organization: ******
Warning: Provided value "foo" is not included in the list of valid values
 - Development/Test
 - Production
 - Disaster Recovery
usage set to "foo".

# syspurpose show
{
  "role": "foo",
  "service_level_agreement": "foo",
  "usage": "foo"
}

With the improvement provided above, Verifying this bug against RHEL 83.

Comment 13 errata-xmlrpc 2020-11-04 01:38:37 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-2020:4460