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.
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.
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
https://gitlab.cloudforms.lab.eng.rdu2.redhat.com/cloudforms/cfme_productization/merge_requests/461
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(-)
Verified on 5.9.0.11.