mirror of
https://github.com/xcat2/confluent.git
synced 2026-06-02 09:19:39 +00:00
Port pyghmi fixes forward
This commit is contained in:
@@ -893,7 +893,7 @@ class IMMClient(object):
|
||||
try:
|
||||
fpga = await self.ipmicmd.raw_command(netfn=0x3a, command=0x6b,
|
||||
data=(0,))
|
||||
fpga = '{0}.{1}.{2}'.format(*bytearray(fpga['data']))
|
||||
fpga = '{0:x}.{1:x}.{2:x}'.format(*bytearray(fpga['data']))
|
||||
yield ('FPGA', {'version': fpga})
|
||||
except pygexc.IpmiException as ie:
|
||||
if ie.ipmicode != 193:
|
||||
@@ -1938,7 +1938,7 @@ class XCCClient(IMMClient):
|
||||
try:
|
||||
fpga = await self.ipmicmd.raw_command(netfn=0x3a, command=0x6b,
|
||||
data=(0,))
|
||||
fpga = '{0}.{1}.{2}'.format(
|
||||
fpga = '{0:x}.{1:x}.{2:x}'.format(
|
||||
*struct.unpack('BBB', fpga['data']))
|
||||
yield 'FPGA', {'version': fpga}
|
||||
except pygexc.IpmiException as ie:
|
||||
|
||||
@@ -1117,7 +1117,7 @@ class Command(object):
|
||||
cidr = _mask_to_cidr(currip['SubnetMask'])
|
||||
retval['ipv4_address'] = '{0}/{1}'.format(currip['Address'], cidr)
|
||||
retval['mac_address'] = netcfg['MACAddress']
|
||||
hasgateway = _mask_to_cidr(currip['Gateway'])
|
||||
hasgateway = _mask_to_cidr(currip['Gateway']) if currip.get('Gateway', None) else None
|
||||
retval['ipv4_gateway'] = currip['Gateway'] if hasgateway else None
|
||||
retval['ipv4_configuration'] = currip['AddressOrigin']
|
||||
tagged = netcfg.get('VLAN', {}).get('VLANEnable', False)
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
import aiohmi.redfish.oem.generic as generic
|
||||
import aiohmi.util.webclient as webclient
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
||||
class OEMHandler(generic.OEMHandler):
|
||||
@@ -28,4 +30,29 @@ class OEMHandler(generic.OEMHandler):
|
||||
sysurl = system['@odata.id']
|
||||
break
|
||||
self._varsysurl = sysurl
|
||||
self._wc = None
|
||||
self.bmc = webclient.thehost
|
||||
self._certverify = webclient.verifycallback
|
||||
return self
|
||||
|
||||
|
||||
async def get_wc(self):
|
||||
self.fwid = None
|
||||
if self._wc:
|
||||
rsp, status = await self._wc.grab_json_response_with_status('/api/chassis-status')
|
||||
if status == 200:
|
||||
return self._wc
|
||||
authdata = {
|
||||
'username': self.username,
|
||||
'password': self.password
|
||||
}
|
||||
wc = webclient.WebConnection(self.bmc, 443, verifycallback=self._certverify)
|
||||
wc.set_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||
rsp, status = await wc.grab_json_response_with_status('/api/session', method='POST', data=urlencode(authdata))
|
||||
if status < 200 or status >= 300:
|
||||
raise Exception('Failed to authenticate to BMC')
|
||||
if 'CSRFToken' in rsp:
|
||||
self.csrftok = rsp['CSRFToken']
|
||||
wc.set_header('X-CSRF-Token', rsp['CSRFToken'])
|
||||
self._wc = wc
|
||||
return wc
|
||||
|
||||
Reference in New Issue
Block a user