HewlettPackard / python-redfish-utility

Python-based utility for interacting with devices supporting a Redfish Service
Other
86 stars 41 forks source link

set IPv4StaticAddresses #60

Closed ralfgro closed 1 year ago

ralfgro commented 1 year ago

I found this issue https://github.com/HewlettPackard/python-redfish-utility/issues/32 but the answer there does not help me to set a static address.

I'm also struggling with setting a static IP to an ILO. Can someone please show a working example? I failed to find one. There are some examples but none that really has all steps in a real world env.

How should I use the example above with HPEs ilorest tool? Why is it so hard to set a static ILO IP with this tool? No working example anywhere.

IPv4StaticAddresses=f"[{{ {ad}, {nm}, {gtw} }}]" if pyhton 3

select EthernetInterface.v1_4_1
get IPv4Addresses --filter "@odata.id=/redfish/v1/Managers/1/EthernetInterfaces/1/"

IPv4StaticAddresses=
                     SubnetMask=255.255.255.0
                     Gateway=172.17.21.1
                     Address=172.17.21.34

 set IPv4StaticAddresses=172.17.21.34 --filter "@odata.id=/redfish/v1/Managers/1/EthernetInterfaces/1/"
'172.17.21.34' is not a valid setting for 'IPv4StaticAddresses', expecting an array

'172.17.21.34' is not a valid setting for 'IPv4StaticAddresses'

set IPv4StaticAddresses=f"[{{ {172.17.21.34}, {255.255.255.0}, {172.17.21.1} }}] --filter "@odata.id=/redfish/v1/Managers/1/EthernetInterfaces/1/"
'f"[{{' is not a valid setting for 'IPv4StaticAddresses', expecting an array

'f"[{{' is not a valid setting for 'IPv4StaticAddresses'
donzef commented 1 year ago

Perso, I use a rawpatch command with the following:

with the following content:

{
    "/redfish/v1/Managers/1/EthernetInterfaces/1/": {
        "DHCPv4": {
            "DHCPEnabled": false,
            "UseDNSServers": false,
            "UseDomainName": false,
            "UseGateway": false,
            "UseNTPServers": false,
            "UseStaticRoutes": false
        },
        "IPv4Addresses": [{
            "Address": "172.228.75.2",
            "Gateway": "172.228.72.1",
            "SubnetMask": "255.255.252.0"
        }]
    }
}
ralfgro commented 1 year ago

Thanks for the hint. It seems that I can't just c&p everything from the get command.

An I first need to select the type. Maybe because I've ilorest version 3.1-

iLOrest > get --json "@odata.id" --filter Name="Manager Dedicated Network Interface"
Unable to locate instance for 'ethernet' and filter 'Name="Manager'
iLOrest > select EthernetInterface.v1_4_1
iLOrest > get --json --filter Name="Manager Dedicated Network Interface"
iLOrest : RESTful Interface Tool version 3.1
Copyright (c) 2014-2020 Hewlett Packard Enterprise Development LP
------------------------------------------------------------------------------------------------------------------------------------------------------
{
  "AutoNeg": true,
  "DHCPv4": {
...
iLOrest > rawpatch /tmp/SetDedicatedEthernetInterface.json

The operation completed successfully.
{
    "/redfish/v1/Managers/1/EthernetInterfaces/1/": {
        "DHCPv4": {
            "DHCPEnabled": false,
            "UseDNSServers": false,
            "UseDomainName": false,
            "UseGateway": false,
            "UseNTPServers": false,
            "UseStaticRoutes": false
       },
       "IPv4Addresses": [{
           "Address": "172.17.21.34",
           "Gateway": "172.17.21.1",
           "SubnetMask": "255.255.255.0"
       }]
    }
}
donzef commented 1 year ago

While it would be a good idea to update to the latest iLOrest version, I've forgotten to specify the selection of the EthernetInterface type in the command retrieving the URI of the dedicated manager interface:

ilorest get --json "@odata.id" --filter Name="Manager Dedicated Network Interface" --select EthernetInterface.

My bad. Sorry.

rajeevkallur commented 1 year ago

{ "@odata.id": "/redfish/v1/Managers/1/EthernetInterfaces/1/" }