Bug 1474175 - Unable to upload the SCAP content file via API with Location and Organization params.
Unable to upload the SCAP content file via API with Location and Organization...
Status: CLOSED NOTABUG
Product: Red Hat Satellite 6
Classification: Red Hat
Component: SCAP Plugin (Show other bugs)
6.2.10
All Linux
medium Severity medium (vote)
: Unspecified
: --
Assigned To: satellite6-bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-24 00:52 EDT by Deepannagaraj Nagarathinam
Modified: 2017-08-07 09:34 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-08-03 02:32:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Upload scap content script (522 bytes, application/x-shellscript)
2017-07-31 03:23 EDT, Ondřej Pražák
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3135671 None None None 2017-08-02 02:25 EDT

  None (edit)
Description Deepannagaraj Nagarathinam 2017-07-24 00:52:33 EDT
Description of problem:

- When trying to upload the SCAP content files to the Satellite server with the Location ID and Organization ID mentioned in the API Call, it fails to upload the Content file to the Satellite server.

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

- Red Hat Satellite v6

How reproducible:

- Always

Steps to Reproduce:

1. Configure the Satellite server with OpenSCAP.

2. Try to upload the SCAP Content file with the location_ids and organization_ids mentioned in the API Call.

Actual results:

- API Call completes successfully, but the Content file is not uploaded to the Satellite server.

Expected results:

- The content file should be uploaded to the Satellite server.

Additional info:

- API Call works fine when the location_ids and organization_ids are not mentioned in the call.

- Able to see the below error at the starting, while running the API Call.

~~~~~~
# bash scap_upload test ssg-rhel7-ds.xml 
Uploading 'ssg-rhel7-ds.xml' file with title name 'test'...
{"status":400,"error":"There was a problem in the JSON you submitted: 795: unexpected token at '{  \"scap_content\": {    \"title\": \"test\",    \"scap_file\":
--- snipped ---
~~~~~~

==> /var/log/foreman/production.log <==

-> With API,

~~~~~~
2017-07-24 00:43:02 [app] [I] Started POST "/api/v2/compliance/scap_contents" for 127.0.0.1 at 2017-07-24 00:43:02 -0400
2017-07-24 00:43:02 [app] [D] Error occurred while parsing request parameters.
 | Contents:
 | 
 | {  "scap_content": {    "title": "test",    "location_ids"=>["2"],     "organization_ids"=>["1"]    "scap_file":

--- snipped ---

2017-07-24 00:43:03 [app] [I] Started HEAD "/" for 127.0.0.1 at 2017-07-24 00:43:03 -0400
2017-07-24 00:43:03 [app] [I] Processing by DashboardController#index as HTML
2017-07-24 00:43:03 [app] [I] Redirected to https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com/users/login
2017-07-24 00:43:03 [app] [I] Filter chain halted as :require_login rendered or redirected
2017-07-24 00:43:03 [app] [I] Completed 302 Found in 20ms (ActiveRecord: 8.4ms)
~~~~~~

-> From WebUI,

~~~~~~
2017-07-24 00:48:08 [app] [I] Started POST "/compliance/scap_contents" for 10.76.0.80 at 2017-07-24 00:48:08 -0400
2017-07-24 00:48:08 [app] [I] Processing by ScapContentsController#create as */*
2017-07-24 00:48:08 [app] [I]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"LsLSRlO7QKRg1h5z+OncmznBa6wJPZalqxKeP752xdI=", "scap_content"=>{"title"=>"scap", "scap_file"=>#<ActionDispatch::Http::UploadedFile:0x007fb253ac0d20 @tempfile=#<Tempfile:/tmp/RackMultipart20170724-31221-uust5f>, @original_filename="ssg-rhel7-ds.xml", @content_type="text/xml", @headers="Content-Disposition: form-data; name=\"scap_content[scap_file]\"; filename=\"ssg-rhel7-ds.xml\"\r\nContent-Type: text/xml\r\n">, "location_ids"=>["", "2"], "organization_ids"=>["", "1"]}}
2017-07-24 00:48:08 [app] [D] Setting current user thread-local variable to admin
2017-07-24 00:48:08 [app] [D] Setting current organization thread-local variable to none
2017-07-24 00:48:08 [app] [D] Setting current location thread-local variable to none
2017-07-24 00:48:08 [app] [D] RestClient.get "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/features", "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate"
 | 
2017-07-24 00:48:08 [app] [D] # => 200 OK | application/json 67 bytes
 | 
2017-07-24 00:48:08 [app] [D] RestClient.get "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/version", "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate"
 | 
2017-07-24 00:48:08 [app] [D] # => 200 OK | application/json 164 bytes
 | 
2017-07-24 00:48:08 [app] [D] RestClient.post "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/compliance/scap_content/validator", 4985633 byte(s) length, "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"4985633", "Content-Type"=>"application/xml"
 | 
2017-07-24 00:48:09 [app] [D] # => 200 OK | text/html 13 bytes
 | 
2017-07-24 00:48:09 [app] [D] RestClient.post "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/compliance/scap_content/policies", 4985633 byte(s) length, "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"4985633", "Content-Type"=>"application/xml"
 | 
2017-07-24 00:48:10 [app] [D] # => 200 OK | text/html 1205 bytes
 | 
2017-07-24 00:48:10 [app] [D] RestClient.post "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/compliance/scap_content/policies", 4985633 byte(s) length, "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"4985633", "Content-Type"=>"application/xml"
 | 
2017-07-24 00:48:10 [app] [D] # => 200 OK | text/html 1205 bytes
 | 
2017-07-24 00:48:10 [app] [I] Redirected to https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com/compliance/scap_contents
2017-07-24 00:48:10 [app] [I] Completed 302 Found in 2356ms (ActiveRecord: 121.5ms)
2017-07-24 00:48:11 [app] [I] Started GET "/compliance/scap_contents" for 10.76.0.80 at 2017-07-24 00:48:11 -0400
2017-07-24 00:48:11 [app] [I] Processing by ScapContentsController#index as */*
2017-07-24 00:48:11 [app] [D] Setting current user thread-local variable to admin
2017-07-24 00:48:11 [app] [D] Setting current organization thread-local variable to none
2017-07-24 00:48:11 [app] [D] Setting current location thread-local variable to none
2017-07-24 00:48:11 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.5.3.18/app/views/scap_contents/_list.html.erb (653.2ms)
2017-07-24 00:48:11 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.5.3.18/app/views/scap_contents/index.html.erb within layouts/application (706.8ms)
2017-07-24 00:48:11 [app] [I]   Rendered common/_searchbar.html.erb (5.3ms)
2017-07-24 00:48:11 [app] [I]   Rendered layouts/_application_content.html.erb (7.8ms)
2017-07-24 00:48:11 [app] [D] Deface: 1 overrides found for 'layouts/base'
2017-07-24 00:48:11 [app] [D] Deface: 'theme_resources' matched 1 times with 'head'
2017-07-24 00:48:11 [app] [I] Deface: [WARNING] No :original defined for 'theme_resources', you should change its definition to include:
 |  :original => '9f26415985aeb5438b8efcaf9078980451df5ff7' 
2017-07-24 00:48:11 [app] [D] Deface: 2 overrides found for 'home/_topbar'
2017-07-24 00:48:11 [app] [D] Deface: 'remove foreman name from topbar' matched 1 times with 'erb[loud]:contains('link_to')'
2017-07-24 00:48:11 [app] [I] Deface: [WARNING] No :original defined for 'remove foreman name from topbar', you should change its definition to include:
 |  :original => '6f86bcbd36e017373b168cc34f62c6deb016bb55' 
2017-07-24 00:48:11 [app] [D] Deface: 'add link to home' matched 1 times with 'erb[loud]:contains('image_tag')'
2017-07-24 00:48:11 [app] [I] Deface: [WARNING] No :original defined for 'add link to home', you should change its definition to include:
 |  :original => '7c247aee58a81a4e49096e83b6a14b07ec780462' 
2017-07-24 00:48:11 [app] [I]   Rendered home/_submenu.html.erb (2.4ms)
2017-07-24 00:48:11 [app] [I]   Rendered home/_user_dropdown.html.erb (4.6ms)
2017-07-24 00:48:11 [app] [I] Read fragment views/tabs_and_title_records-3 (0.1ms)
2017-07-24 00:48:11 [app] [I]   Rendered home/_topbar.html.erb (12.4ms)
2017-07-24 00:48:11 [app] [I]   Rendered layouts/base.html.erb (23.1ms)
2017-07-24 00:48:11 [app] [I] Completed 200 OK in 812ms (Views: 530.5ms | ActiveRecord: 266.7ms)
~~~~~~
Comment 1 Ondřej Pražák 2017-07-31 03:23 EDT
Created attachment 1306816 [details]
Upload scap content script
Comment 2 Ondřej Pražák 2017-07-31 04:30:21 EDT
The 400 error message suggests posting a malformed JSON, which is the reason why scap content is not created. I am afraid the script in the attached customer case is the culprit. Notice there are missing commas in version posted on Jul 12, when location_ids and organization_ids were added. I modified the script and was able to upload the scap content, the updated script version is attached here. Could you find out if the updated version works for the customer?
Comment 3 Deepannagaraj Nagarathinam 2017-07-31 22:34:41 EDT
Hi Ondřej,

Thank you. I have tried the script in my test Satellite and it worked fine.

I hope it will work for the customer too. I will update the BZ once I hear back from customer.

Deepannagaraj N.
Comment 4 Deepannagaraj Nagarathinam 2017-08-02 01:14:11 EDT
Hi Ondřej,

Customer has confirmed that the corrected --new-- script works fine. Thank you so much for your help and sorry for the silly mistake.

I think we are good to close this BZ as NOTABUG.

Deepannagaraj N.
Comment 5 Ondřej Pražák 2017-08-03 02:32:45 EDT
Thank you, closing as per comment #4.

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