ansible-collections / community.general

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

Keeping odata IDs in redfish resources ? #7316

Open pyfontan opened 1 year ago

pyfontan commented 1 year ago

Summary

I have a problem to identify network devices on HPe servers. I would like to have a specific ID for each redfish resource.

Perhaps one should keep @odata.id in final resources.

Issue Type

Feature Idea

Component Name

redfish_info

Additional Information

With the following playbook:

    - name: Get Network card information
      community.general.redfish_info:
        category: Systems
        command: GetNicInventory
        baseuri: "{{ asset.manager.ip }}"
        username: "{{ asset.manager.user }}"
        password: "{{ asset.manager.password }}"
        timeout: "{{ redfish_timeout | default(omit) }}"
      register: rfnicinfo
      delegate_to: "{{manager_proxy_server}}"

We can have description of each Ethernet interface.

    "redfish_facts": {                                                                                                                                          
        "nic": {                                                                                                                                                
            "entries": [                                                                                                                                        
                [                                                                                                                                               
                    {                                                                                                                                           
                        "resource_uri": "/redfish/v1/Systems/1/"                                                                                                
                    },                                                                                                                                          
                    [                                                                                                                                           
                        {                                                                                                                                       
                            "IPv4Addresses": [],                                                                                                                
                            "IPv6Addresses": [],                                                                                                                
                            "Id": "1",                                                                                                                          
                            "MACAddress": "ff:ff:ff:ff:ff:ff",                                                                                                  
                            "Name": "",                                                                                                                         
                            "NameServers": [],                                                                                                                  
                            "SpeedMbps": null,                                                                                                                  
                            "Status": {                                                                                                                         
                                "Health": "OK",                                                                                                                 
                                "State": "Enabled"                                                                                                              
                            }                                                                                                                                   
                        },                                                                                                                                      
                        {         
                            "IPv4Addresses": [],                                                                                                                
                            "IPv6Addresses": [],                                                                                                                
                            "Id": "2",
                            "MACAddress": "ff:ff:ff:ff:ff:ff",
                            "Name": "",
                            "NameServers": [],
                            "SpeedMbps": null,
                            "Status": {
                                "Health": null,
                                "State": null
                            }
                        },
                        {
                            "AutoNeg": true,
                            "Id": "1",
                            "Name": "Ethernet Interface 1",
                            "PermanentMACAddress": "ff:ff:ff:ff:ff:ff",
                            "SpeedMbps": 10000,
                            "Status": {
                                "Health": "OK",
                                "State": "Enabled"
                            }
                        },
                        {
                           "AutoNeg": true,
                            "Id": "2",
                            "Name": "Ethernet Interface 2",
                            "PermanentMACAddress": "ff:ff:ff:ff:ff:ff",
                            "SpeedMbps": 0,
                            "Status": {
                                "Health": "OK",
                                "State": "Enabled"
                            }
                        }
                    ]
                ]
           ],
            "ret": true
        }
    }

But as you can see, IDs are not unique... I've never seen that on DELL servers, but HPe did. :(

I would like to be able to specify an ID as a variable to my playbook. And in my use case, ID must be unique on a single server but can be the same on multiple servers of the same type. So MACAddress can't be used.

I thought that keeping the @odata.id in the resource would be a good idea ?

Code of Conduct

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

Yeah, I can see that coming up in other implementations too. Id is only guaranteed to be unique for a given resource collection (and not across the entire service). Having the full URI would be useful. I'd like to avoid calling it @odata.id in the output payload if possible.

pyfontan commented 3 days ago

@mraineri I started to write something for disks resources which is named RedfishURI (see #8937). I'm thinking of implementing the same thing for network interfaces. Is it OK for you ?

mraineri commented 3 days ago

It's definitely in the right direction; I have one suggested addition in the PR to review, but I'm liking the changes so far!