Bug 1451142

Summary: service now integrations for determining host_name return empty array
Product: Red Hat CloudForms Management Engine Reporter: Jeffrey Cutter <jcutter>
Component: AutomateAssignee: William Fitzgerald <wfitzger>
Status: CLOSED CURRENTRELEASE QA Contact: Tasos Papaioannou <tpapaioa>
Severity: high Docs Contact:
Priority: high    
Version: 5.7.0CC: cpelland, jcutter, jhardy, kmorey, mkanoor, obarenbo, simaishi, tfitzger, tpapaioa
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1462309 1465084 (view as bug list) Environment:
Last Closed: 2018-03-06 15:25:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1462309, 1465084    

Description Jeffrey Cutter 2017-05-15 22:54:00 UTC
Description of problem:

The Service Now integrations create, update, and update_patch located in:

/ RedHat / Integration / ServiceNow / CMDB

Use the following to determine the host_name which returns an empty array on 5.7.0 on line 51 in create as an example:

host_name   = $evm.object['host_name']   || get_virtual_column_value(vm, :hostnames)

From a rails console:

irb(main):041:0> $evm.vmdb(:vm).all[1].hostnames
=> []
irb(main):042:0> $evm.vmdb(:vm).all[1].host_name
=> "rhvh2.example.com"

Seems we shouldn't use hostnames on CFME 5.7 for this purpose?


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

5.7.1.3.20170221135006_818f133

How reproducible:

Always

Steps to Reproduce:
1. Include create in your VM provisioning state machine.
2. Note host_name ends up as []

Actual results:

host_name = []

Expected results:

host_name = actual_hostname

Additional info:

Note that this VM is on RHV 4.0.7.4-0.1.el7ev as the provider.

Comment 2 Greg McCullough 2017-05-17 17:19:26 UTC
After a bit of research I am sorry to say this is not the correct solution.  The host_name property on the VM object is not what you would expect.  It actually returns the name of the associated host.  (Poorly named and we may need to consider changing, but it has been around for a long time so that may make it difficult.)

The hostnames is the proper value since that looks up VM's host_names based on the networking data collected during the refresh.

So the question is what should this code be doing if we do not have a valid VM hostname?  Should it loop to see if one becomes available or exit with an error?


Also wanted to let you know that for your rails console example you can avoid loading all the VM objects by calling:
  $evm.vmdb(:vm).first

This will avoid having to load every VM object and they only use one.  Should be much quicker, depending on the size of your environment.

Comment 3 Jeffrey Cutter 2017-05-17 19:33:39 UTC
It doeesn't really matter to me where it comes from, only that it has a valid value.  [] didn't work for the customer and we were able to work around the issue using .host_name understanding that may not be the intended value, it was what the customer seemed to be expecting.

I often use .first, but in this case, the .first wasn't helpful and it's just my small lab, so I went to the second one.

Thanks,
-Jeff

Comment 8 CFME Bot 2017-06-14 21:43:04 UTC
New commit detected on cfme_productization/master:
https://code.engineering.redhat.com/gerrit/gitweb?p=cfme_productization.git;a=commit;h=30f4966cfaaa8c8a655256751b2e80b277daa365

commit 30f4966cfaaa8c8a655256751b2e80b277daa365
Author:     william fitzgerald <wfitzger>
AuthorDate: Fri May 19 12:27:23 2017 -0400
Commit:     william fitzgerald <wfitzger>
CommitDate: Fri May 19 12:27:23 2017 -0400

    Automate - Modified 3 methods for host_name in RedHat domain.
    
    host_name was receiving null values.
    
    The Service Now integrations create, update, and update_patch located in:
    
    / RedHat / Integration / ServiceNow / CMDB
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1451142

 .../RedHat/Integration/ServiceNow/CMDB.class/__methods__/create.rb  | 6 +++++-
 .../RedHat/Integration/ServiceNow/CMDB.class/__methods__/update.rb  | 6 +++++-
 .../Integration/ServiceNow/CMDB.class/__methods__/update_patch.rb   | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

Comment 11 Tasos Papaioannou 2017-11-29 17:48:46 UTC
Verified on 5.9.0.11.