Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage_pod can not be set #1247

Closed
afeefghannam89 opened this issue Jun 15, 2021 · 14 comments · Fixed by #1686
Closed

storage_pod can not be set #1247

afeefghannam89 opened this issue Jun 15, 2021 · 14 comments · Fixed by #1686

Comments

@afeefghannam89
Copy link

afeefghannam89 commented Jun 15, 2021

SUMMARY

I am using compute_profile plugin to create configuration on katello. However, this plugin let the storage_pod parameter empty after problem free Ansible run

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
2.9.17
COLLECTION VERSION
v2.1.0
KATELLO/FOREMAN VERSION
tfm-rubygem-katello-3.16.0.20-1.el7sat.noarch
foreman-2.1.2.25-1.el7sat.noarch
STEPS TO REPRODUCE
- name: Create compute profiles
  theforeman.foreman.compute_profile:
    name: "{{ item.name }}"
    compute_attributes: "{{ item.compute_attributes }}"
    server_url: "{{ satellite_url }}"
    username: "{{ satellite_admin_username }}"
    password: "{{ satellite_admin_password }}"
    state: "{{ item.state | default(omit) }}"
  loop: "{{ compute_profiles  | default([]) }}"
  when: compute_profiles is defined
  no_log: yes


###here is the host_vars:
compute_profiles:
  - name: Small
    compute_attributes:
    - compute_resource: ""
      vm_attrs:
        cluster: Cluster
        resource_pool: Resources
        cpus: 1
        corespersocket: 1
        memory_mb: 2048
        firmware: bios
        guest_id: rhel8_64Guest
        ha: 1
        scsi_controllers:
        - type: ParaVirtualSCSIController
        volumes_attributes:
          0:
            size_gb: 100
            thin: false
            mode: persistent
            storage_pod: VPLEX
        interfaces_attributes:
          0:
            type: VirtualVmxnet3
            network: VLAN51

............
EXPECTED RESULTS

Set the storage-pod parameter in my Small compute profile

ACTUAL RESULTS

@evgeni
Copy link
Member

evgeni commented Jun 15, 2021

Can you post the output of ansible-playbook --check --diff playbook.yml when the profile is not yet present? And ideally another one when it is.

@afeefghannam89
Copy link
Author

afeefghannam89 commented Jun 16, 2021

ansible-playbook --check --diff redhat_satellite.yml -i on_prem_environment/inventory

PLAY [redhat_satellite] ***************************************************************************************************************************************************************************************************************************************

TASK [redhat_satellite : Include tasks to configure satellite] ************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/satellite-config.yml for example-katello.com

TASK [redhat_satellite : Include infrastructure task] *********************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/infrastructure.yml for example-katello.com

TASK [redhat_satellite : Create compute profiles] *************************************************************************************************************************************************************************************************************
--- before
+++ after
@@ -1,8 +1,43 @@
 {
     "compute_attributes": [
-        {}
+        {
+            "compute_resource_id": 3,
+            "id": -1,
+            "vm_attrs": {
+                "cluster": "348-CPU-DC-Cluster",
+                "corespersocket": 1,
+                "cpus": 1,
+                "firmware": "bios",
+                "guest_id": "rhel8_64Guest",
+                "ha": 1,
+                "interfaces_attributes": {
+                    "0": {
+                        "network": "dvportgroup-257",
+                        "type": "VirtualVmxnet3"
+                    }
+                },
+                "memory_mb": 2048,
+                "resource_pool": "Resources",
+                "scsi_controllers": [
+                    {
+                        "type": "ParaVirtualSCSIController"
+                    }
+                ],
+                "volumes_attributes": {
+                    "0": {
+                        "mode": "persistent",
+                        "size_gb": 100,
+                        "storage_pod": "group-p666",
+                        "thin": false
+                    }
+                }
+            }
+        }
     ],
     "compute_profiles": [
-        {}
+        {
+            "id": -1,
+            "name": "Small"
+        }
     ]
 }

changed: [example-katello.com] => (item={u'name': u'Small', u'compute_attributes': [{u'compute_resource': u'VMware Central Intel', u'vm_attrs': {u'resource_pool': u'Resources', u'memory_mb': 2048, u'volumes_attributes': {0: {u'size_gb': 100, u'storage_pod': u'DatastoreCluster-Server-INTEL-VPLEX', u'thin': False, u'mode': u'persistent'}}, u'interfaces_attributes': {0: {u'type': u'VirtualVmxnet3', u'network': u'VLAN51_DC_VM_SRV_PLT-BEK'}}, u'guest_id': u'rhel8_64Guest', u'firmware': u'bios', u'cpus': 1, u'scsi_controllers': [{u'type': u'ParaVirtualSCSIController'}], u'cluster': u'348-CPU-DC-Cluster', u'corespersocket': 1, u'ha': 1}}]})

PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************
example-katello.com : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

After creating the profile:

 ansible-playbook --check --diff redhat_satellite.yml -i on_prem_environment/inventory

PLAY [redhat_satellite] ***************************************************************************************************************************************************************************************************************************************

TASK [redhat_satellite : Include tasks to configure satellite] ************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/satellite-config.yml for example-katello.com

TASK [redhat_satellite : Include infrastructure task] *********************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/infrastructure.yml for example-katello.com

TASK [redhat_satellite : Create compute profiles] *************************************************************************************************************************************************************************************************************
ok: [example-katello.com] => (item={u'name': u'Small', u'compute_attributes': [{u'compute_resource': u'VMware Central Intel', u'vm_attrs': {u'resource_pool': u'Resources', u'memory_mb': 2048, u'volumes_attributes': {0: {u'size_gb': 100, u'storage_pod': u'DatastoreCluster-Server-INTEL-VPLEX', u'thin': False, u'mode': u'persistent'}}, u'interfaces_attributes': {0: {u'type': u'VirtualVmxnet3', u'network': u'VLAN51_DC_VM_SRV_PLT-BEK'}}, u'guest_id': u'rhel8_64Guest', u'firmware': u'bios', u'cpus': 1, u'scsi_controllers': [{u'type': u'ParaVirtualSCSIController'}], u'cluster': u'348-CPU-DC-Cluster', u'corespersocket': 1, u'ha': 1}}]})

PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************
example-katello.com: ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

I tried with group-p666 as a storage pod name, but I got the same results.
Two screenshots are attached confirming the empty storage pod field after creating the profile and the available choices.

Small compute profile

available choices

@evgeni
Copy link
Member

evgeni commented Jun 16, 2021

Thanks!

Another request (sorry!)

Can you select the right pod in the UI, save it, and then again run the playbook with --diff and show us?

Background: the output you posted implies the API did accept the pod, but if the UI disagrees, we might be using a wrong identifier or something?

@afeefghannam89
Copy link
Author

afeefghannam89 commented Jun 16, 2021

 ansible-playbook --check --diff redhat_satellite.yml -i on_prem_environment/inventory

PLAY [redhat_satellite] ***************************************************************************************************************************************************************************************************************************************

TASK [redhat_satellite : Include tasks to configure satellite] ************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/satellite-config.yml for example-katello.com

TASK [redhat_satellite : Include infrastructure task] *********************************************************************************************************************************************************************************************************
included: /home/elmvp/bag-bdpa-helper/roles/redhat_satellite/tasks/infrastructure.yml for example-katello.com

TASK [redhat_satellite : Create compute profiles] *************************************************************************************************************************************************************************************************************
--- before
+++ after
@@ -4,44 +4,30 @@
             "compute_resource_id": 3,
             "id": 55,
             "vm_attrs": {
-                "add_cdrom": "0",
-                "annotation": "",
-                "boot_order": [
-                    "network",
-                    "disk"
-                ],
                 "cluster": "348-CPU-DC-Cluster",
-                "corespersocket": "1",
-                "cpuHotAddEnabled": "0",
-                "cpus": "1",
+                "corespersocket": 1,
+                "cpus": 1,
                 "firmware": "bios",
                 "guest_id": "rhel8_64Guest",
-                "hardware_version": "Default",
-                "image_id": "",
+                "ha": 1,
                 "interfaces_attributes": {
                     "0": {
                         "network": "dvportgroup-257",
                         "type": "VirtualVmxnet3"
                     }
                 },
-                "memoryHotAddEnabled": "0",
-                "memory_mb": "2048",
-                "path": "/Datacenters/BK-DC-INTEL/vm",
+                "memory_mb": 2048,
                 "resource_pool": "Resources",
                 "scsi_controllers": [
                     {
-                        "key": 1000,
                         "type": "ParaVirtualSCSIController"
                     }
                 ],
                 "volumes_attributes": {
                     "0": {
-                        "controller_key": 1000,
-                        "datastore": null,
                         "mode": "persistent",
-                        "name": "Hard disk",
                         "size_gb": 100,
-                        "storage_pod": "DatastoreCluster-Server-INTEL-VPLEX",
+                        "storage_pod": "group-p666",
                         "thin": false
                     }
                 }

changed: [example-katello.com] => (item={u'name': u'Small', u'compute_attributes': [{u'compute_resource': u'VMware Central Intel', u'vm_attrs': {u'resource_pool': u'Resources', u'memory_mb': 2048, u'volumes_attributes': {0: {u'size_gb': 100, u'storage_pod': u'DatastoreCluster-Server-INTEL-VPLEX', u'thin': False, u'mode': u'persistent'}}, u'interfaces_attributes': {0: {u'type': u'VirtualVmxnet3', u'network': u'VLAN51_DC_VM_SRV_PLT-BEK'}}, u'guest_id': u'rhel8_64Guest', u'firmware': u'bios', u'cpus': 1, u'scsi_controllers': [{u'type': u'ParaVirtualSCSIController'}], u'cluster': u'348-CPU-DC-Cluster', u'corespersocket': 1, u'ha': 1}}]})

PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************
example-katello.com : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

I think, the problem is, the plugin uses the pod id "group-p666" by creating or checking the pod parameter, that does not match with katello API, I think katello wants the pod name not the pod id, does it? Have a look please at the network name and compare it with the pod, the plugin uses the network id dvportgroup-257 by creating and checking which suits katello API.

@evgeni
Copy link
Member

evgeni commented Jun 16, 2021

Interesting, thanks!

@evgeni
Copy link
Member

evgeni commented Jun 16, 2021

Out of curiosity, did you try deploying a host with the "broken" (the one using the id, not name) compute profile?

I have a feeling this should work and the UI is just displaying it wrongly, but don't have a VMware to test on :(

@afeefghannam89
Copy link
Author

afeefghannam89 commented Jun 16, 2021

Your feeling is right :) I used the name as pod name

 storage_pod: DatastoreCluster-Server-INTEL-VPLEX

The UI does not display the pod under the profile, but while creating a virtual machine, I can see the pod under the vm configurations. In addition, the creating of new vm works.

@evgeni
Copy link
Member

evgeni commented Jun 22, 2021

"nice"

We'll try get access to an VMware to test this and other parameters properly and issue a fix afterwards.

cc @ezr-ondrej for "how broken is this intergration?!"

@laugmanuel
Copy link
Member

I've experienced the same problem with FAM 2.2.0.
The behaviour changed probably due to d0050d1.

I can assist in debugging FAM (and Foreman) if you need someone with access to VMware.

@lovilak
Copy link

lovilak commented Dec 15, 2021

Hello,
I've tried this change : volume['storage_pod'] = storage_pod['name'] instead of
volume['storage_pod'] = storage_pod['id'] in plugins/modules/compute_profile.py and the storage_pod is displayed.

@afeefghannam89
Copy link
Author

@evgeni Hello, I can confirm the solution from @lovilak. I have tested it with collection 3.8 and RedHat Satellite 6.10.7.

I have tested also the storage_domain with name and id It worked in both cases. storage_pod works only with name but not with id

@s-reimann
Copy link

same here, changing storage_pod['id'] to storage_pod['name'] did the trick. I've tested with collection 3.8 and foreman-3.4.1-1

@brakkio86
Copy link

Hello, I'm facing the same issue. I've a fresh installation of RH Satellite 6.14.0 (i.e. foreman-3.7.0.9-1.el8sat.noarch) and collection 3.10.0. There is any fix for this situation?

@brakkio86
Copy link

I've tried the fix suggested by @s-reimann and implemented a pull request #1686.

@evgeni evgeni linked a pull request Dec 12, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants