Bug 1282537

Summary: authentication_userid/authentication_password methods missing for Foreman provider
Product: Red Hat CloudForms Management Engine Reporter: ncatling
Component: AutomateAssignee: Greg McCullough <gmccullo>
Status: CLOSED WONTFIX QA Contact: Jan Krocil <jkrocil>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 5.4.0CC: cpelland, gmccullo, jfrey, jhardy, mkanoor, nachandr, ncatling, obarenbo, simaishi, tfitzger
Target Milestone: GA   
Target Release: cfme-future   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: automate:foreman
Fixed In Version: 5.5.0.11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-07 18:46:50 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:

Description ncatling 2015-11-16 17:09:31 UTC
Description of problem:

authentication_userid/authentication_password methods missing for Foreman/Configuration Manager provider. Following error produced:

NoMethodError: undefined method `authentication_userid' for #<MiqAeMethodService::MiqAeServiceProvisioningManagerForeman:0x000000075d0320>


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

5.4.3.1


How reproducible:


Steps to Reproduce:
1. Add Satellite 6 provider
2. Access rails console
3. Execute following: $evm.vmdb('ext_management_system').all.each { |ems| puts ems.authentication_userid }

Actual results:

irb(main):022:0> $evm.vmdb('ext_management_system').all.each { |ems| puts ems.authentication_userid }
  ExtManagementSystem Load (0.3ms)  SELECT "ext_management_systems".* FROM "ext_management_systems" 
  ExtManagementSystem Inst Including Associations (0.9ms - 9rows)
  Authentication Load (0.3ms)  SELECT "authentications".* FROM "authentications" WHERE "authentications"."resource_id" = 1000000000006 AND "authentications"."resource_type" = 'ExtManagementSystem'
  Authentication Inst Including Associations (0.1ms - 1rows)
admin
  Authentication Load (0.2ms)  SELECT "authentications".* FROM "authentications" WHERE "authentications"."resource_id" = 1000000000007 AND "authentications"."resource_type" = 'ExtManagementSystem'
  Authentication Inst Including Associations (0.2ms - 3rows)
admin
  Authentication Load (0.2ms)  SELECT "authentications".* FROM "authentications" WHERE "authentications"."resource_id" = 1000000000009 AND "authentications"."resource_type" = 'ExtManagementSystem'
  Authentication Inst Including Associations (0.1ms - 2rows)
admin@internal
NoMethodError: undefined method `authentication_userid' for #<MiqAeMethodService::MiqAeServiceProvisioningManagerForeman:0x000000075d0320>
	from /var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_service_model_base.rb:176:in `method_missing'
	from (irb):22:in `block in irb_binding'
	from (irb):22:in `each'
	from (irb):22
	from /opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/commands/console.rb:47:in `start'
	from /opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/commands/console.rb:8:in `start'
	from /opt/rh/cfme-gemset/bundler/gems/rails-4842a8377644/railties/lib/rails/commands.rb:41:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'



Expected results:

authentication_userid/authentication_password should be displayed.

Additional info:

Comment 2 ncatling 2015-11-16 17:14:40 UTC
*** Bug 1282541 has been marked as a duplicate of this bug. ***

Comment 3 Greg McCullough 2015-11-19 22:20:56 UTC
Nick - The steps to reproduce are not valid from the rails console as written because $evm is nil when you start the rails console.

If you have steps for reproducing in console please provide the full steps otherwise it seems like the steps should state that the logic needs to be run from an automate method.

Comment 4 ncatling 2015-11-19 23:01:24 UTC
This is the missing bit:
$evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)

Comment 5 ncatling 2015-11-19 23:02:40 UTC
This is the missing bit:
$evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)

Comment 6 Greg McCullough 2015-11-20 13:23:30 UTC
This was recently fixed in https://github.com/ManageIQ/manageiq/pull/5397 as part of Bug 1280350.

Moving this ticket to POST so QE can validate this scenario as it was not identified as an issue in the original bug.

Updated steps to Reproduce:
1. Add Satellite 6 provider
2. Access rails console
3. Execute following: 
$evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)
$evm.vmdb('ext_management_system').all.each { |ems| puts ems.authentication_userid }

Comment 10 Greg McCullough 2015-11-30 16:19:44 UTC
The Sat6/Foreman provider is setup different from other management_systems.  The main object is defined in the Provider model and has multiple "management systems" called managers which are derived from the ext_management_system model which is why you see 2 records there for a Foreman provider.

The credentials are set on the Provider object and not on the managers which is why you are seeing the nil.  Foreman needs to access the credentials at the Provider model layer, but they are currently not exposed to automate.

Comment 12 Chris Pelland 2017-06-07 18:46:50 UTC
This BZ has been closed since it was opened on a version of CloudForms that has reached the end of its lifecycle.  If you find that this bug is still relevant, please open a new BZ against the relevant supported version of CloudForms.