IBM / ansible-power-hmc

Developer contributions for Ansible Automation on Power (HMC)
GNU General Public License v3.0
26 stars 39 forks source link

get_MS_names_by_lpar_name not enough values to unpack (expected 2, got 1) #124

Closed MalfuncEddie closed 4 days ago

MalfuncEddie commented 4 months ago

Describe the bug A clear and concise description of what the bug is.

following playbook gives errors on all lpars

    - name: Get facts
      powervm_lpar_instance:
        hmc_host: '{{ lookup("env", "HMC_HOST") }}'
        hmc_auth:
          username: '{{ lookup("env", "HMC_USER") }}'
          password: '{{ lookup("env", "HMC_PASSWORD") }}'
        vm_name: "{{ inventory_hostname }}"
        advanced_info: True
        state: facts
      register: lpar
      delegate_to: localhost

inventory

plugin: ibm.power_hmc.powervm_inventory
hmc_hosts:
  - hmc: '{{ lookup("env", "HMC_HOST") }}'
    user: '{{ lookup("env", "HMC_USER") }}'
    password: '{{ lookup("env", "HMC_PASSWORD") }}'
identify_unknown_by: PartitionName
compose:
  server_name: SystemName
keyed_groups:
  - prefix: "server_group"
    key: SystemName
  - prefix: "partition_type"
    key: PartitionType

returns

The full traceback is:
  File "/tmp/ansible_powervm_lpar_instance_payload_38f69mi3/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/modules/powervm_lpar_instance.py", line 1558, in partition_details
  File "/tmp/ansible_powervm_lpar_instance_payload_38f69mi3/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/modules/powervm_lpar_instance.py", line 984, in identify_ManagedSystem_of_lpar
  File "/tmp/ansible_powervm_lpar_instance_payload_38f69mi3/ansible_powervm_lpar_instance_payload.zip/ansible_collections/ibm/power_hmc/plugins/modules/powervm_lpar_instance.py", line 974, in get_MS_names_by_lpar_name
fatal: [censored]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "action": null,
            "advanced_info": true,
            "all_resources": null,
            "delete_vdisks": null,
            "hmc_auth": {
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
            },
            "hmc_host": "censored",
            "iIPLsource": null,
            "install_settings": null,
            "keylock": null,
            "max_mem": null,
            "max_proc": null,
            "max_proc_unit": null,
            "max_virtual_slots": null,
            "mem": null,
            "min_mem": null,
            "min_proc": null,
            "min_proc_unit": null,
            "npiv_config": null,
            "os_type": null,
            "physical_io": null,
            "proc": null,
            "proc_compatibility_mode": null,
            "proc_mode": null,
            "proc_unit": null,
            "prof_name": null,
            "restart_option": null,
            "retain_vios_cfg": null,
            "shared_proc_pool": null,
            "shutdown_option": null,
            "state": "facts",
            "system_name": null,
            "virt_network_config": null,
            "vm_id": null,
            "vm_name": "censored",
            "vnic_config": null,
            "volume_config": null,
            "weight": null
        }
    },
    "msg": "ValueError('not enough values to unpack (expected 2, got 1)')"
}

I think this is hmc related since other hmc do work.

To Reproduce Execute the playbook

Expected behavior Get the facts of the server

Environment (please complete the following information):

Additional context Add any other context about the problem here.

MalfuncEddie commented 4 months ago

I added

raise Error(ms) before line 981 to see what ms is

GXX-XXXX-XXX-SNXXXX,Operating

so the split should work. Not understanding why this does not work

MalfuncEddie commented 4 months ago

Ok looks like the profiles i tried to list wat lpm-ed but never booted on a managed systems. this only retruns the state and not the name of the managed system. I fixed it by excluding the "unknowns" for the inventory

I also changed get_MS_names_by_lpar_name

https://github.com/IBM/ansible-power-hmc/blob/0af0a1fb88186ffd6708d83681ffe44146f77cc6/plugins/modules/powervm_lpar_instance.py#L977

def get_MS_names_by_lpar_name(hmc_obj, lpar_name):
    mss = hmc_obj.list_all_managed_system_details("name,state")
    ms_list = []
    for ms in mss:
        if len(ms.split(',')) < 2:
            if ms == "Off":
                continue
            else:
                raise Exception("Only one Argument+" + ms)
        ms_name, state = ms.split(',')
        if state == 'Operating':
            lpar_names = hmc_obj.list_all_lpars_details(ms_name, "name")
            if lpar_name in lpar_names:
                ms_list.append(ms_name)
    return ms_list

If it only gets "Off" that it continues to the next loop.

naveenkandakur commented 4 months ago

This is an issue, we will fix it.

naveenkandakur commented 4 days ago

Taken care as of August-2024 release content, hence closing this.