2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-28 11:57:34 +00:00

Fallback to direct ipv4addresses manipulation

A redfish implementation may forbid writing to it,
however others allow only writing to it.

Change-Id: If4e1f6a737cb6b1460d73cbe9faf30c18951f890
This commit is contained in:
Jarrod Johnson 2019-07-22 13:42:37 -04:00
parent b6fb57dfa5
commit 5860b3796a

View File

@ -940,6 +940,7 @@ class Command(object):
ipv4_gateway=None):
patch = {}
ipinfo = {}
dodhcp = None
netmask = None
if ipv4_address:
if '/' in ipv4_address:
@ -953,12 +954,22 @@ class Command(object):
patch['IPv4StaticAddresses'] = [ipinfo]
ipinfo['Gateway'] = ipv4_gateway
if ipv4_configuration.lower() == 'dhcp':
dodhcp = True
patch['DHCPv4'] = {'DHCPEnabled': True}
elif (ipv4_configuration == 'static'
or 'IPv4StaticAddresses' in patch):
dodhcp = False
patch['DHCPv4'] = {'DHCPEnabled': False}
if patch:
self._do_web_request(self._bmcnicurl, patch, 'PATCH')
try:
self._do_web_request(self._bmcnicurl, patch, 'PATCH')
except exc.RedfishError as e:
patch = {'IPv4Addresses': [ipinfo]}
if dodhcp:
ipinfo['AddressOrigin'] = 'DHCP'
elif dodhcp is not None:
ipinfo['AddressOrigin'] = 'Static'
self._do_web_request(self._bmcnicurl, patch, 'PATCH')
def get_net_configuration(self):
netcfg = self._do_web_request(self._bmcnicurl, cache=False)