From 1e445ad526e9fc511d20dcea45bac28eecb7621d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 14 Aug 2020 17:42:49 -0400 Subject: [PATCH] Have configbmc actually consume bmcconfig data /usr/libexec/platform-python /opt/confluent/bin/apiclient /confluent-api/self/bmcconfig -j > /tmp/whatever.json /usr/libexec/platform-python configbmc.py -i /tmp/whatever.json --- misc/configbmc.py | 107 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 8 deletions(-) diff --git a/misc/configbmc.py b/misc/configbmc.py index f35fe75b..1ce7dbfc 100644 --- a/misc/configbmc.py +++ b/misc/configbmc.py @@ -15,7 +15,9 @@ import argparse import ctypes import fcntl +import json from select import select +import socket import struct import sys import time @@ -142,9 +144,10 @@ def set_port(s, port, vendor, model): if vendor not in ('IBM', 'Lenovo'): raise Exception('{0} not implemented'.format(vendor)) if _is_tsm(model): - set_port_tsm(s, port, model) + return set_port_tsm(s, port, model) else: set_port_xcc(s, port, model) + return 1 def set_port_tsm(s, port, model): @@ -155,16 +158,22 @@ def set_port_tsm(s, port, model): s.raw_command(0x32, 0x71, b'\x00\x01\x00') elif port == 'dedicated': s.raw_command(0x32, 0x71, b'\x00\x00\x00') + else: + raise Exception("Unsupported port for TSM") timer = 15 while timer: time.sleep(1.0) sys.stdout.write('.') sys.stdout.flush() if port == 'ocp': + iface = 0 s.raw_command(0x32, 0x71, b'\x00\x00\x03') elif port == 'dedicated': + iface = 1 s.raw_command(0x32, 0x71, b'\x00\x01\x03') + rsp = s.raw_command(0x32, 0x72, bytearray(4, iface, 0)) print('Complete') + return int(rsp['data'][0]) def set_port_xcc(s, port, model): @@ -200,7 +209,7 @@ def set_port_xcc(s, port, model): sys.stdout.write('Complete\n') -def set_vlan(s, vlan): +def set_vlan(s, vlan, channel): ovlan = vlan if vlan == 'off': vlan = b'\x00\x00' @@ -209,11 +218,13 @@ def set_vlan(s, vlan): if vlan: vlan = vlan | 32768 vlan = struct.pack('