Bug 1937470 - hammer does not have a compute resource associate VMs command as web UI has
Summary: hammer does not have a compute resource associate VMs command as web UI has
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Compute Resources
Version: 6.8.0
Hardware: Unspecified
OS: Unspecified
medium vote
Target Milestone: 6.11.0
Assignee: aabramov
QA Contact: Lukáš Hellebrandt
: 1774104 2027351 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2021-03-10 17:37 UTC by Vedashree Deshpande
Modified: 2022-07-18 23:42 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2027351 (view as bug list)
Last Closed: 2022-07-05 14:28:45 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 32271 0 Normal Closed hammer does not have a compute resource associate VMs command as web UI has 2021-11-18 14:33:26 UTC
Foreman Issue Tracker 32769 0 High Closed Associate a VM via API to a compute resource 2021-11-18 14:33:27 UTC
Foreman Issue Tracker 33047 0 Normal Closed Associate a single VM via hammer to a compute resource 2021-11-18 14:33:30 UTC
Red Hat Product Errata RHSA-2022:5498 0 None None None 2022-07-05 14:29:24 UTC

Description Vedashree Deshpande 2021-03-10 17:37:45 UTC
Description of problem:
hammer host update does not update a specific host. 
example: # hammer host update --id 39 --compute-resource VMWARE

Even if the host id is specified, all the VMs get associated to the VMware mentioned as the Compute resource. 

Actual results:
All the guest VMs get updated. 

Expected results:
Only a specific VM should be updated.

Comment 1 Yifat Makias 2021-03-11 10:24:53 UTC
This is weird because if the host is not VMware it shouldn't update it to VMware without providing any other relevant compute attributes, When I tried to do this I received this error:
Could not update the host:
  Failed to find compute attributes, please check if VM marty-lintner.tlv.redhat.com was deleted

However, when I try to update a parameter that can be changed without any more attributes (for example hostname) the update works well and updates only the host that I specified with the --id option.
So I am not sure there is a bug here.

Can you please provide more details on the host you are trying to update?

Comment 2 Vedashree Deshpande 2021-03-11 12:39:07 UTC
Hello Yifat, 

The expectations in customers words are as follows: 

I need to automate the "Associate VM" task for a specific VM. This task is usually performed by the Satellite GUI, on the Compute Resource section.

Currently, I'm able to automate it only by using the following API call, however doing so it also associates all the VMs to the compute resource, instead of only the required one:

curl --header "Content-Type:application/json" --request PUT --user username:password --insecure https://satellite.example.com/api/v2/compute_resources/2/associate | python -m json.tool

So the previous command you provided me:

# hammer host update --id 39 --compute-resource VMWARE

doesn't have any issue, but it doesn't meet my needs, because using it the host hasn't been associated with the compute resource. In fact it doesn't have the power controls on the host screen in the GUI.
This command adds only the "Deploy on" entry in the host settings, and it doesn't actually execute the "Associate VM" task such as from the GUI (in Compute Resource section).


I hope this helps to get clarity of the issue.

Comment 3 Yifat Makias 2021-04-08 11:17:45 UTC
Created redmine issue https://projects.theforeman.org/issues/32271 from this bug

Comment 4 Bryan Kearney 2021-04-22 16:02:31 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/32271 has been resolved.

Comment 6 Lukáš Hellebrandt 2021-07-12 14:19:17 UTC
With Sat 6.10.0 snap 5.0:

# hammer compute-resource --help | grep associate-vms
 associate-vms                 Associate VMs to Hosts
# hammer compute-resource associate-vms --help
    hammer compute-resource associate-vms [OPTIONS]
 --id ID
# hammer compute-resource associate-vms --id 65
Virtual machines have been associated.

=> The machine has indeed been associated with the CR. The CR is filled correctly in Host -> Edit -> Deploy on and power operations work. Note this happens for all the machines on that CR.

Comment 7 Lukáš Hellebrandt 2021-07-12 14:46:03 UTC
Failed as per comment 6. While it is nice that it is now possible to associate all the VMs on a certain CR, that's not what customer asked for. Customer wants to be able to associate one single VM, not all the VMs on a CR.

Comment 8 Tomer Brisker 2021-07-22 07:21:25 UTC
Connecting redmine issue https://projects.theforeman.org/issues/33047 from this bug

Comment 9 Yifat Makias 2021-07-22 08:06:27 UTC
*** Bug 1774104 has been marked as a duplicate of this bug. ***

Comment 17 Lukáš Hellebrandt 2022-02-02 16:38:11 UTC
Verified with Sat 7.0 snap 7.0 but a followup BZ reported.

I have Hosts created with MAC addresses of lhellebr-bz2, respectively lhellebr-bz3 VMs set as a precondition, none of them is associated to any CR.

# hammer compute-resource --help | grep associate
 associate-vms                 Associate VMs to Hosts
# hammer compute-resource associate-vms --help | grep vm-id
 --vm-id VALUE                           Associate a specific VM
# hammer compute-resource virtual-machines --id 1 | grep bz
500dc585-b074-b7ee-a1ec-332f40a698cb | lhellebr-bz3                                           
500d8cfc-6442-a658-147f-bd9717a90ac5 | lhellebr-bz2
# hammer compute-resource associate-vms --id 1 --vm-id 500d8cfc-6442-a658-147f-bd9717a90ac5
Virtual machines have been associated.
# hammer compute-resource associate-vms --id 1 --vm-id 500d8cfc-6442-a658-147f-beefface
Could not associate the virtual machines:
  Resource compute_resource not found by id '1'

=> Looking in WebUI, I see that lhellebr-bz2 has been associated to the CR and lhellebr-bz3 has not been associated to anything.
However, when in the second associate-vms call, I purposefully used an incorrect VM id, a misleading error appeared stating that CR id is incorrect while in fact, VM id is incorrect.

Comment 18 Lukáš Hellebrandt 2022-02-02 16:43:36 UTC
Followup BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2049759

Comment 21 errata-xmlrpc 2022-07-05 14:28:45 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 (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Comment 22 Brad Buckingham 2022-07-18 23:42:59 UTC
*** Bug 2027351 has been marked as a duplicate of this bug. ***

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