ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
836 stars 1.53k forks source link

Redfish VirtualMediaInsert does not work for Supermicro #6969

Open ppeereb1 opened 1 year ago

ppeereb1 commented 1 year ago

Summary

Currently I have this playbook:

- name: Ejecting {{ image }} on {{ bmc_ip }}
  redfish_command:
    category: Manager
    command: VirtualMediaEject
    baseuri: "{{ bmc_ip }}"
    username: "{{ user }}"
    password: "{{ password }}"
    virtual_media: 
      image_url: '{{ Image }}'
    resource_id: 1
  ignore_errors: true # Don't fail when no image is inserted.

- name: Get Virtual Media information
  community.general.redfish_info:
    category: Manager
    command: GetVirtualMedia
    baseuri: "{{ bmc_ip }}"
    username: "{{ user }}"
    password: "{{ password }}"
  register: result

- name: debug
  debug:
    var: result

- name: Insert virtual media
  redfish_command:
    category: Manager
    command: VirtualMediaInsert
    baseuri: "{{ bmc_ip }}"
    username: "{{ user }}"
    password: "{{ password }}"
    virtual_media:
      image_url: "{{ new_image_url }}"
      media_types:
        - CD
    resource_id: 1

This results in the following output:

TASK [during_install : Ejecting http://10.10.10.10:8080/bogus.iso ] ***
ok: [localhost]

TASK [during_install : Get Virtual Media information] **************************
ok: [localhost]

TASK [during_install : debug] **************************************************
ok: [localhost] => {
    "result": {
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "virtual_media": {
                "entries": [
                    [
                        {
                            "resource_uri": "/redfish/v1/Managers/1"
                        },
                        [
                            {
                                "ConnectedVia": "NotConnected",
                                "Id": "CD1",
                                "Image": "http://10.10.10.10:8080/bogus.iso",
                                "ImageName": "bogus.iso",
                                "MediaTypes": [
                                    "CD",
                                    "DVD"
                                ],
                                "Name": "Virtual Removable Media",
                                "TransferMethod": "Stream",
                                "TransferProtocolType": "HTTP",
                                "WriteProtected": true
                            }
                        ]
                    ]
                ],
                "ret": true
            }
        }
    }
}
TASK [during_install : Insert virtual media] ***********************************
fatal: [prov-51L02-09.lw.odcnoord.nl]: FAILED! => {"changed": false, "msg": "Unable to find an available VirtualMedia resource supporting ['CD']"}

I thought this: https://github.com/ansible-collections/community.general/pull/4839 would fix it but i'm using 7.2.0 version. I think it's failing because Image/ImageName already is configured?

Issue Type

Bug Report

Component Name

community.general.redfish_command

Ansible Version

ansible [core 2.15.1]
  config file = /root/.ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 7.2.0

# /usr/local/lib/python3.10/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 7.1.0

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = /root/.ansible.cfg

OS / Environment

Ubuntu 22.04 docker image

Steps to Reproduce

See summary

Expected Results

See summary

Actual Results

Code of Conduct

ansibullbot commented 1 year ago

Files identified in the description: None

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 1 year ago

cc @TSKushal @bhavya06 @jyundt @mraineri @rajeevkallur @renxulei @tomasg2012 @xmadsen click here for bot help

mraineri commented 1 year ago

Yes, that's what appears to be happening here. Since Image still contains the URI of the media, that virtual media slot won't be recognized as available, so the insert request fails.

Would you be able to run the eject step without the option to ignore errors?

ppeereb1 commented 1 year ago

Hi @mraineri yes I've checked on a BMC that did not had the Image property set and there it succeeds. I could not find a way to remove the image entry. The ejecting of the image is just successfull:

- name: Ejecting {{ Image }} on {{ bmc_ip }}
  redfish_command:
    category: Manager
    command: VirtualMediaEject
    baseuri: "{{ bmc_ip }}"
    username: "{{ user }}"
    password: "{{ password }}"
    virtual_media:
      image_url: '{{ Image }}'
    resource_id: 1
  register: debug

- name: debug
  debug:
    var: debug

- name: Get Virtual Media information
  community.general.redfish_info:
    category: Manager
    command: GetVirtualMedia
    baseuri: "{{ bmc_ip }}"
    username: "{{ user }}"
    password: "{{ password }}"
  register: result

- name: result
  debug:
    var: result

Output:

TASK [during_install : Ejecting http://10.10.10.10:8080/bogus.iso] ***
ok: [localhost]
TASK [during_install : debug] **************************************************
ok: [localhost] => {
    "debug": {
        "changed": false,
        "failed": false,
        "msg": "Action was successful",
        "return_values": {},
        "session": {}
    }
}

TASK [during_install : Get Virtual Media information] **************************
ok: [localhost]
TASK [during_install : result] *************************************************
ok: [localhost] => {
    "result": {
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "virtual_media": {
                "entries": [
                    [
                        {
                            "resource_uri": "/redfish/v1/Managers/1"
                        },
                        [
                            {
                                "ConnectedVia": "NotConnected",
                                "Id": "CD1",
                                "Image": "http://10.10.10.10:8080/bogus.iso",
                                "ImageName": "bogus.iso",
                                "MediaTypes": [
                                    "CD",
                                    "DVD"
                                ],
                                "Name": "Virtual Removable Media",
                                "TransferMethod": "Stream",
                                "TransferProtocolType": "HTTP",
                                "WriteProtected": true
                            }
                        ]
                    ]
                ],
                "ret": true
            }
        }
    }
}

This works, but would rather use the redfish module:

- name: Insert virtual Media
  ansible.builtin.uri:
    url: https://{{ bmc_ip }}/redfish/v1/Managers/1/VirtualMedia/CD1/Actions/VirtualMedia.InsertMedia
    method: POST
    force_basic_auth: true
    user: {{ user }}
    password: "{{ password }}"
    headers:
      Content-Type: application/json
    body_format: json
    body:
      Image: "{{ new_image_url }}"
    status_code: 202
mraineri commented 1 year ago

After you insert the media, what's shown in the response to "GetVirtualMedia"? I'm hoping there's something we can key off of to know if we should attempt any sort of workaround.

Do you also know if Supermicro is aware of this issue? While we can make workarounds to bypass the issue, I'd really like Supermicro to fix their implementation since this is clearly a bug and not conformant with the standard.

ppeereb1 commented 1 year ago

This is the output of GetVirtualMedia when an image is inserted:

TASK [during_install : debug] **************************************************
ok: [prov-51L02-09.lw.odcnoord.nl] => {
    "result": {
        "changed": false,
        "failed": false,
        "redfish_facts": {
            "virtual_media": {
                "entries": [
                    [
                        {
                            "resource_uri": "/redfish/v1/Managers/1"
                        },
                        [
                            {
                                "ConnectedVia": "URI",
                                "Id": "CD1",
                                "Image": "http://10.10.10.10:8080/bogus.iso",
                                "ImageName": "bogus.iso",
                                "MediaTypes": [
                                    "CD",
                                    "DVD"
                                ],
                                "Name": "Virtual Removable Media",
                                "TransferMethod": "Stream",
                                "TransferProtocolType": "HTTP",
                                "WriteProtected": true
                            }
                        ]
                    ]
                ],
                "ret": true
            }
        }
    }

The only thing that could to be validated is the ConnectedVia property. Supermicro is currently not aware of this issue. I will check internally in my company to see if we have support on these machines. The behaviour of the VirtualMediaEject should be that it clears the image & imageName property?

I've updated the BMC firmware to latest available: Firmware Revision: 01.74.02

mraineri commented 1 year ago

That's right, we have this text in the long description:

At the completion of the operation, inserted shall be set to false and the image name shall be cleared.

The image name certainly isn't cleared after the media is ejected.

We also have this statement for the image string:

The value null shall indicates no image connection.

So, based on these statements, I would expect "ImageName" to be an empty string and "Image" to be null.

mraineri commented 1 year ago

And yes, I think we can use the "ConnectedVia" property as a way of helping with a workaround to this issue.

jyundt commented 1 year ago

Do you also know if Supermicro is aware of this issue? While we can make workarounds to bypass the issue, I'd really like Supermicro to fix their implementation since this is clearly a bug and not conformant with the standard.

@ppeereb1 Can you provide the SMC server model? I can also dig into this one a little bit.

ppeereb1 commented 1 year ago

We have this one: SYS-1029U-TR25M https://www.supermicro.com/en/products/system/1u/1029/sys-1029u-tr25m.cfm

jyundt commented 1 year ago

@ppeereb1

Got it, thank you! Because this is an X11 based platform, I think it's going to be unlikely that this will be "fixed" via a FW release. But let me try to dig into this a bit.